
<template>
  <div class="accountList">
    <div class="searchBox">
      <el-form :model="searchForm" ref="searchFormRef">
        <el-row>
          <el-form-item prop="createName">
            <div class="item">
              <span v-html="'创建人'" class="nameSpan"></span>
              <el-input
                size="mini"
                v-model="searchForm.createName"
                placeholder="请输入名称"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item prop="createPhone">
            <div class="item">
              <span v-html="'创建账号'" class="nameSpan"></span>
              
              <el-input
                size="mini"
                v-model="searchForm.createPhone"
                placeholder="请输入创建人"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item>
            <el-button
              @click="searchClick"
              icon="el-icon-search"
              type="primary"
              size="mini"
              >查询</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="resetClick"
              >重置</el-button
            >
          </el-form-item>
        </el-row>
      </el-form>
    </div>

    <div class="tableBox" ref="tableBoxRef">
      <el-table
      :height="654"
        v-loading="tableLoading"
        :header-cell-style="{
          background: '#F8F8F8',
          color: '#333',
          fontSize: '16px',
          fontWeight: '700',
        }"
        border
        :data="tableData"
        style="width: 100%"
      >
        <el-table-column
          prop="name"
          align="center"
          label="姓名"
           
        >
        </el-table-column>
        <el-table-column
          prop="school"
          align="center"
          label="毕业学校"
           
        >
        </el-table-column>
        <el-table-column
          prop="speciality"
          align="center"
          label="专业"
           
        >
        </el-table-column>
        <el-table-column
          prop="education"
          align="center"
          label="学历"
           
        >
        </el-table-column>
        <el-table-column
          prop="createName"
          align="center"
          label="创建人"
           
        >
        </el-table-column>
        <el-table-column
          prop="createAccount"
          align="center"
          label="创建账号"
           
        >
        </el-table-column>
        <el-table-column
          prop="createTime"
          align="center"
          label="创建时间"
           
        >
          <template slot-scope="scope">{{
            scope.row.createTime | formatDate
          }}</template>
        </el-table-column>

        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              icon="el-icon-edit-outline"
              size="mini"
              type="text"
              v-has="'system:user:edit'"
              @click="changeDetail(scope.row)"
              >查看详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>

       <el-card class="footer" v-if="total > 0">
         <div>
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNum"
          :page-sizes="[15, 30, 50, 100]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
        </el-card>
    </div>
    <!-- 新增/修改权限 -->
    <el-dialog :close-on-click-modal="false" 
      title="查看详情"
      :visible.sync="changeVisible"
      width="1000px"
      class="addEditAccountDialog"
    >
       <div class="content">
        <div class="title">基本信息</div>
        <div class="line"></div>
        <el-row>
            <el-col :span='8'>姓名：{{detailData.name}}</el-col>
            <el-col :span='8'>性别：{{genderFor[detailData.gender]}}</el-col>
            <el-col :span='8'>出生日期：<span v-if='detailData.birthday'>{{detailData.birthday| formatDate}}</span></el-col>
        </el-row>
        <el-row style="margin-top:20px">
            <el-col :span='8'>毕业院校：{{detailData.school}}</el-col>
            <el-col :span='8'>专业：{{detailData.speciality}}</el-col>
            <el-col :span='8'>学历：{{detailData.education}}</el-col>
        </el-row>
        <el-row  style="margin-top:20px">
            <el-col :span='8'>身份证号码：{{detailData.idCard}}</el-col>
            <el-col :span='8'>联系电话：{{detailData.mobile}}</el-col>
        </el-row>
          <div style="margin-top:40px"  class="title">教育经历</div>
        <div class="line"></div>
        <div  class="line-height">
            {{detailData.educationalExperience}}
        </div>
         <div style="margin-top:40px"  class="title">工作经历</div>
        <div class="line"></div>
        <div  class="line-height">
            {{detailData.workExperience}}
        </div>
        <div style="margin-top:40px"  class="title">培训经历</div>
        <div class="line"></div>
        <div  class="line-height">
            {{detailData.trainingExperience}}
        </div>
       </div>
         <div class="btns">
        <el-button
          v-clickForbidden
          size="mini"
          type="primary"
          @click="changeVisible = false"
          >确 定</el-button
        >
      </div>
    </el-dialog>
    
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      changeVisible: false,
      searchForm: {
        createName:"",
        createPhone:'',
        

      },
      tableLoading: false,
      tableHeight: 50,
      tableData: [],
      pageNum: 1,
      pageSize: 15,
      total: 0,
        detailData:{},
        genderFor:{
          0:"男",
          1:"女"
        }
    };
  },

  computed: {
    ...mapGetters(["permissions"]),
  },
  created() {
    this.getAssessList();
  },
  methods: {

   async changeDetail(row) {
        this.changeVisible=true
          
          const res = await  this.$api.assessDetail(row.id);
          if (res.data.code == "00000") {
            this.detailData=res.data.result
          }
       
    },
    searchClick() {
      this.pageNum = 1;
      this.getAssessList();
    },
    resetClick() {
      this.$refs.searchFormRef.resetFields();
      this.pageNum = 1;
      this.getAssessList();
    },

    /**
     * 获取用户列表
     * @param {*}
     */
    async getAssessList() {
      this.tableLoading = true;
      await this.$api
        .assessList({
          size: this.pageSize,
          page: this.pageNum,
          condition: {
            ...this.searchForm,
          },
        })
        .then((res) => {
            if(res.data.code=='00000'){
                 this.total = res.data.result.total;
          this.tableData = res.data.result.records;
      
          this.tableLoading = false;
            }
         
        });
    },

    /**
     * 切换页面大小
     * @param {*} val
     */
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.getAssessList();
    },

    /**
     * 页码切换
     * @param {*} val
     */
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pageNum = val;
      this.getAssessList();
    },
  },
};
</script>

<style lang="less" scoped>
.accountList {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  .searchBox {
    .el-row {
      display: flex;
      flex-wrap: wrap;
      .el-form-item {
        margin-bottom: 0;
      }
      .item {
        display: flex;
        align-items: center;
        margin-right: 20px;
        .nameSpan {
          padding-right: 10px;
          box-sizing: border-box;
          white-space: nowrap;
        }
        .el-input {
          width: 162px;
        }
      }
    }
  }
   .topBtn {
    margin: 10px 0;
text-align: right;
  }
  .addEditAccountDialog {
    .content{
      padding: 20px;
        .line{
            margin: 20px 0;
          height: 1px; background-color: gray; transform:scaleY(0.5);
        }
        .line-height{
          line-height: 20px;
        }
        .title{
          font-weight: 600;
          font-size: 16px;
        }
    }
    .el-form-item {
      .el-select {
        width: 100%;
      }
    }
    .btns {
      text-align: right;
      margin-bottom: 0;
    }
  }
}
/deep/.el-button--success.is-plain {
  color: #fff;
  border-color: #409eff;
  background-color: #409eff;
}
/deep/.el-form-item {
  margin-bottom: 12px;
}
.content {
  height: 60vh;
  overflow-x: hidden;
}
.footer {
  z-index: 500;
  position: fixed;
  bottom: 0;
  width: 100%;
  line-height: var(--footer-height);
  color: #fff;

}
</style>